package com.qst.rongxiaoserver.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.util.Date;

import static com.baomidou.mybatisplus.annotation.FieldFill.INSERT;

@TableName("tb_user")
@Data
public class UserModel {
    @TableId(type= IdType.AUTO)
    @Pattern(regexp = "^[a-zA-Z][A-Za-z0-9]{2,9}+$",message = "账号必须以字母开头，长度在3-10之间，只能包含英文字符、数字")
    private String userName;

    @Pattern(regexp = "^[a-zA-Z][a-zA-Z0-9_]{5,17}$",message = "密码必须以字母开头，长度在6-18之间，只能包含英文字符、数字和下划线")
    private String password;
    @NotBlank(message = "昵称不能为空")
    private String nickName;

    private String realName;
    @Pattern(regexp = "^1[3|4|5|7|8][0-9]{9}$",message = "请输入正确的手机号")
    private String phone;
    @Pattern(regexp = "^\\d{15}|\\d{18}$",message = "请输入15或18位有效身份证号")
    private String identityNum;
    @Size(min = 2,max = 30,message = "请输入的地址长度在2-30之间")
    private String address;
//     3个角色， 用户 user , 专家 expert 管理员 admin
    @Pattern(regexp = "^(user|expert|admin)$",message = "设置角色请输入 user,expert,admin 等角色")
    private String role;

    @TableField(value = "create_time", fill = INSERT)
    private Date createTime;
    @TableField(value = "update_time", fill = INSERT)
    private Date updateTime;

    private int integral;
    private int credit;
    private String avatar;
}
